package cn.tedu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class ShopController {

    private String name;

    public ShopController() {
        System.out.println("1.通过Constructor实例化对象");
    }

    @Value("水杯")
    public void setName(String name) {
        this.name = name;
        System.out.println("2.通过set方法注入属性值");
    }

    @PostConstruct
    public void init(){
        System.out.println("3.执行生命周期的初始化");
    }

    @PreDestroy
    public void destory(){
        System.out.println("5.bean对象销毁,释放资源");
    }
}
